import java.util.Arrays;

public class Learn_4_24 {

    public static void main (String[] args) {

        int[] arr = {1, 2, 34, 3, 4, 5, 7, 23, 12};
        boolean flag = false;
        for (int i = 0; i < arr.length - 3; i++) {
            if (arr[i] % 2 != 0) {
                if (arr[i + 1] % 2 != 0 && arr[i + 2] % 2 != 0) flag = true;
            }
        }
        System.out.println (flag);

    }

    //不相同的话进行消除，总数减一，相同的话总数加一
    public static void main7 (String[] args) {
        int[] arr = {2, 2, 3, 4, 2, 2, 2, 5, 6};
        int target = arr[0];
        int count = 1;
        for (int i = 1; i < arr.length; i++) {
            if (count > 0) {
                if (target == arr[i]) count++;
                else count--;
            } else {
                target = arr[i];
                count++;
            }
        }
        System.out.println (target);
    }

    public static void main6 (String[] args) {
        int[] arr = {4, 1, 2, 1, 2};
        int flag = 0;
        int an = 0;

        for (int i = 0; i < arr.length; i++) {
            for (int j = i + 1; j < arr.length; j++) {
                if (arr[i] == arr[j]) {
                    flag = 1;
                    break;
                }
            }
            if (flag == 0) {
                an = arr[i];
                break;
            }
        }
        System.out.println (an);
    }

    public static void main5 (String[] args) {
        int[] arr = {2, 3, 4, 5, 6};
        int target = 7;
        int flag = 0;
        int i = 0;
        int j = 0;
        for (i = 0; i < arr.length; i++) {
            for (j = i + 1; j < arr.length - 1; j++) {
                if ((arr[i] + arr[j]) == target) {
                    flag = 1;
                    break;
                }
            }
            if (flag == 1) break;
        }
        System.out.println ("[" + i + "," + j + "]");
    }

    public static void main4 (String[] args) {
        int[] arr = {6, 7, 4, 5, 3, 2, 9, 8};
        System.out.println (Arrays.toString (arr));
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                int temp = 0;
                if (arr[j] > arr[j + 1]) {
                    temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        System.out.println ("排序后：");
        System.out.println (Arrays.toString (arr));
    }

    public static void main3 (String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7};
        System.out.println (Arrays.toString (arr));
        for (int i = 0; i < arr.length; i++) {
            for (int j = i; j < arr.length - 1; j++) {
                int temp = 0;
                if (arr[j] % 2 != 0) {
                    temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        System.out.println (Arrays.toString (arr));
    }

    public static void main2 (String[] args) {
        double[] arr = {2, 3, 4, 5, 6};
        System.out.println ("平均值是：");
        System.out.println (avg (arr));
    }

    public static double avg (double[] a) {
        double sum = 0;
        for (int i = 0; i < a.length; i++) {
            sum += a[i];
        }
        return sum / a.length;
    }

    public static void main1 (String[] args) {
        int[] arr = {1, 2, 3};
        System.out.println (Arrays.toString (arr));
        transform (arr);
        System.out.println (Arrays.toString (arr));

    }

    public static int[] transform (int[] a) {
        int[] b = a;
        for (int i = 0; i < a.length; i++) {
            b[i] = a[i] * 2;
        }
        return b;
    }

}
